package cn.vivi.tag.service.impl;

import cn.vivi.common.entity.BlogTag;
import cn.vivi.tag.mapper.BlogTagMapper;
import cn.vivi.tag.service.BlogTagService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class BlogTagServiceImpl implements BlogTagService {

    @Autowired
    private BlogTagMapper blogTagMapper;

    @Override
    public boolean deleteByTagId(String id) {
        QueryWrapper<BlogTag> wrapper = new QueryWrapper<>();
        wrapper.eq("tag_id", id);
        if (blogTagMapper.selectCount(wrapper) == 0) {
            return true;
        }
        return blogTagMapper.delete(wrapper) > 0;
    }

}
